﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace DEMO_TEMP1
{
    public partial class Login : Form
    {
       string userid = String.Empty;

        public Login()
        {
            InitializeComponent();
            //panel1.Enabled = false;
        }
        //public string User_id()
        //{
        //  return  userid = id;
        //}
        private void menuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
           
        }
        DataSet ds = new DataSet();
        bool chlogin;
        string id = string.Empty;
        private void menuItem2_Click(object sender, EventArgs e)
        {
            login_func();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            login_func();
        }




        private void login_func()
        {

            id = textBox1.Text;
            string pass = textBox2.Text;
            //localhost.Service1 con = new localhost.Service1();
            WebPor.Service1 con = new WebPor.Service1();
            con.Url = string.Format("http://192.168.1.220/WebAppPor01/Service1.asmx");
            //chlogin = con.Conect(id,pass );
            // chlogin = con.Connect_CallSto(id, pass);
            ds = con.CallStoReal(id, pass, "EICS HHT", "MY PDA", "YES", "1.0");
            if (ds == null)
            {
                chlogin = false;
            }
            else
            {
                if (ds.Tables[0].Rows[0]["Column1"].ToString() == "PASS")
                {
                    chlogin = true;
                }
                else if (ds.Tables[0].Rows[0]["Column1"].ToString() == "WARNING")
                {
                    chlogin = false;
                }
                else
                {
                    chlogin = false;
                }


            }
            if (chlogin)
            {
                //label3.Visible = true;
                //////DateTime start = new DateTime();

                //////while (new DateTime().Ticks < start.Ticks + 1) //1000 for 1000 milliseconds 
                //////{

                //////}

                //label3.Text = "WARNING PASSWORD NEARLY EXPIRE ";
                //label3.
                // label3.

                userid = id;

                Form1 f1 = new Form1(userid);
                f1.Show();


            }
            else
            {
                if (ds.Tables[0].Rows[0]["Column1"].ToString() == "WARNING")
                {
                    label3.Visible = true;
                    label3.Enabled = true;
                    label3.Text = ds.Tables[0].Rows[0]["Column3"].ToString();
                    chlogin = true;
                }
                else
                {
                    label3.Visible = true;
                    label3.Text = ds.Tables[0].Rows[0]["Column3"].ToString();
                }

            }
          
        }

    }
}